/*
 * Project:     My Project Work, Copyright (C) 2011
 * Created at:  19.08.2011
 */
package de.myprojectwork.view;

import de.myprojectwork.common.util.Logger;
import de.myprojectwork.common.util.MyProjectWorkException;
import de.myprojectwork.model.DataManipulationModelImpl;
import de.myprojectwork.presenter.TodoPresenter;
import de.myprojectwork.presenter.TodoPresenterImpl;
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.JFrame;

/**
 * @author Chris Holdschuh
 */
public class MainFrameImpl extends JFrame implements MainFrame {
    
    private AbstractView todoView;

    public MainFrameImpl() {
        TodoPresenter todoPresenter = new TodoPresenterImpl(new DataManipulationModelImpl());
        todoView = new TodoViewImpl(todoPresenter);
        todoPresenter.setView(todoView);
    }
    
    @Override
    public void initUi() {
        setTitle("My Project Work");
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setSize(1024, 768);
        setLocationRelativeTo(null);

        // Views initialisieren
        try {
            todoView.getPresenter().initUi();
            
        } catch (MyProjectWorkException e) {
            Logger.error(e.getMessage(), e);
        }
        
        // Layout
        GridBagLayout layout = new GridBagLayout();
        setLayout(layout);
        layout.setConstraints(todoView, new GridBagConstraints(0, 0, 0, 0, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
        add(todoView);
        
        
        
        
        //pack();
        setVisible(true);
    }
    
}
